#ifndef __WD_BLOCKQ_H
#define __WD_BLOCKQ_H

#include <func.h>
#define N 1024

typedef struct {
    int elements[N];
    int front;
    int rear;
    int size;
    // 不满
    pthread_cond_t not_full;
    // 不空
    pthread_cond_t not_empty;
    // 互斥锁
    pthread_mutex_t mutex;
} blockq_t;

// API
blockq_t* blockq_create(void);
void blockq_destroy(blockq_t* q);
bool blockq_isempty(blockq_t* q);
bool blockq_isfull(blockq_t* q);
int blockq_peek(blockq_t* q);
int blockq_pop(blockq_t* q);
void blockq_push(blockq_t* q, int task);

#endif

